﻿using CCWin;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using 群智感知激励系统服务端底层;

namespace 群智感知激励系统服务端
{
    public partial class 系统日志窗口 : CCSkinMain
    {
        public 系统日志窗口()
        {
            InitializeComponent();
        }
        int id = 1;
        private void 系统日志窗口_Load(object sender, EventArgs e)
        {
            try
            {
                skinListView1.Items.Clear();
                lock (系统日志.系统日志列表)
                {
                    foreach (系统日志 i in 系统日志.系统日志列表)
                    {
                        ListViewItem lvi = new ListViewItem();
                        lvi.Text = id.ToString();
                        lvi.SubItems.Add(i.内容);
                        lvi.SubItems.Add(i.时间戳);
                        skinListView1.Items.Add(lvi);
                        id++;
                    }
                }
            }
            catch { }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                lock (系统日志.系统日志列表)
                {
                    if (skinListView1.Items.Count == 0)
                    {
                        skinListView1.BeginUpdate();
                        foreach (系统日志 i in 系统日志.系统日志列表)
                        {
                            ListViewItem lvi = new ListViewItem();
                            lvi.Text = id.ToString();
                            lvi.SubItems.Add(i.内容);
                            lvi.SubItems.Add(i.时间戳);
                            skinListView1.Items.Add(lvi);
                            id++;
                        }
                        skinListView1.EndUpdate();
                    }
                    int 记录差 = 系统日志.系统日志列表.Count - skinListView1.Items.Count;
                    if (记录差 > 0)
                    {
                        skinListView1.BeginUpdate();
                        for (int i = skinListView1.Items.Count; i < 系统日志.系统日志列表.Count; i++)
                        {
                            ListViewItem lvi = new ListViewItem();
                            lvi.Text = id.ToString();
                            lvi.SubItems.Add(系统日志.系统日志列表[i].内容);
                            lvi.SubItems.Add(系统日志.系统日志列表[i].时间戳);
                            skinListView1.Items.Add(lvi);
                            id++;
                        }
                        skinListView1.EndUpdate();
                    }
                }
            }
            catch { }
        }
    }
}
